package com.link.base.base.orgnization.dao.mybatis.mapper;

import com.link.base.base.orgnization.model.LinkTable;
import com.link.base.base.orgnization.model.Orgnization;
import com.link.base.base.system.model.TreeNode;
import com.link.base.ext.emp.model.ExtEmployee;
import com.link.core.basic.dao.mapper.BasicMapper;
import com.link.core.basic.model.CallParam;

import java.util.List;

/**
 * @author history update 18.11.05
 */
public interface OrgnizationMapper extends BasicMapper<Orgnization> {

    /**
     * 查询根组织
     *
     * @param entity
     * @return Orgnization
     * @throws Exception
     */
    public Orgnization queryRoot(Orgnization entity) throws Exception;

    /**
     * 查询组织列表表排除主键为Id的组织和其子组织，只取有效的信息
     *
     * @param entity
     * @return List
     * @throws Exception
     */
    public List<Orgnization> queryListRemoveIdAndChildrenPage(Orgnization entity) throws Exception;

    /**
     * 存储过程更新RUN_ORG_UPDATE
     *
     * @param record
     * @throws Exception
     */
    public void getRunOrgUpdate(com.link.core.basic.model.CallParam record) throws Exception;

    /**
     * 存储过程更新RUN_ORG_SUB_UPDATE
     *
     * @param record
     * @throws Exception
     */
    public void getRunOrgSubUpdate(CallParam record) throws Exception;

    /**
     * 查询组织中的所有公司
     *
     * @param entity
     * @return List
     * @throws Exception
     */
    public List<Orgnization> queryCompanyInOrgnizationSelect(Orgnization entity) throws Exception;

    /**
     * 获取子孙组织的id串
     * @author l
     * @param entity
     * @return String
     * @throws Exception
     */
    public String getOrgChildStr(Orgnization entity) throws Exception;

    /**
     * 更新企点部门ID
     *
     * @param entity
     * @throws Exception
     */
    public void qdDeptIdUpdate(Orgnization entity) throws Exception;

    /**
     * 查询联系人的组织
     * @author huanglongjian
     * @param entity
     * @return List
     * @throws Exception
     * @ 查询联系人的组织
     */
    public List<Orgnization> queryOrgByContactId(Orgnization entity) throws Exception;

    /**
     * 查询客户的组织
     * @author huanglongjian
     * @param entity
     * @return List
     * @throws Exception
     * @ 查询联系人的组织
     */
    public List<Orgnization> queryOrgByAccountId(Orgnization entity) throws Exception;

    /**
     * 删除当前状态下所有组织
     * @param orgnization
     * @throws Exception
     */
    public void deleteCorpOrg(Orgnization orgnization) throws Exception;

    /**
     * 插入默认组织
     * @param orgnization
     * @throws Exception
     */
    public void insertCorpOrg(CallParam orgnization) throws Exception;

    /**
     * 查询唯一的000账套下的默认组织
     * @param orgnization
     * @return org
     * @throws Exception
     */
    public Orgnization queryByCorpOrgCode(Orgnization orgnization) throws Exception;

    /**
     * 查询当前账套下的所有组织
     * @param record
     * @return List
     * @throws Exception
     */
    public List<Orgnization> queryCorpOrgList(Orgnization record) throws Exception;

    /**
     * 查询当前账套下的所有组织，有别于queryCorpOrgList方法，该方法用户生成组织树
     *
     * @author LiYang
     * @date 2019/12/12
     * @param record
     * @return List
     * @throws Exception
     */
    public List<TreeNode> queryAllOrgList(Orgnization record) throws Exception;

    /**
     * 查询当前账套下的所有组织平铺关系
     *
     * @author LiYang
     * @date 2019/12/12
     * @param record
     * @return List
     * @throws Exception
     */
    public List<TreeNode> queryOrgRelList(Orgnization record) throws Exception;

    /**
     * 删除当前账套下中间表的组织数据
     * @param orgnization
     * @throws Exception
     */
    public void deleteCorpInnerOrg(Orgnization orgnization) throws Exception;

    /**
     * 往当前账套下的组织拉平中间表插入组织数据
     * @param org
     * @throws Exception
     */
    public void insertPartyRel(Orgnization org) throws Exception;

    /**
     * 批量往拉平表插入组织/部门数据
     * @param orgList
     * @throws Exception
     */
    public void insertPartyRelList(List<Orgnization> orgList) throws Exception;

    /**
     * 拿到数据库所有表的表相关内容
     *
     * @author yangxiaolin
     * @date 2019/03/11 15:24
     * @param entity
     */
    List<LinkTable> queryTableInfoList(LinkTable entity) throws Exception;

    /**
     * 拿到数据库某表的所有列相关内容
     *
     * @author yangxiaolin
     * @date 2019/03/11 15:24
     * @param entity
     */
    List<LinkTable> queryColInfoListByTableName(LinkTable entity) throws Exception;

    /**
     * 更新数据库某表的某字段
     *
     * @author yangxiaolin
     * @date 2019/03/11 15:24
     * @param entity
     */
    public void saveCombineOrg(LinkTable entity) throws Exception;

    /**
     * 更改组织状态
     * @author yangxiaolin
     * @date 2019/03/11 15:24
     * @param linkTable
     * @throws Exception
     */
    public void orgStatusUpdate(LinkTable linkTable) throws Exception;

    /**
     * 通过orgId找到所属以及一级子公司
     *
     * @author NingLanhao
     * @date 2019-03-27 14:30
     * @param entity
     * @return com.link.business.base.orgnization.model.Orgnization
     */
    Orgnization queryCompanyByOrgId(Orgnization entity) throws Exception;

    /**
     * 通过组织id和组织类型，获取上级或下级组织信息
     * @author 秦学刚
     * @date 2019/04/30 01:16
     * @param orgnization
     */
    public List<Orgnization> queryTierOrgnization(Orgnization orgnization) throws Exception;

    /**
     * 根据组织编码查询组织
     *
     * @param orgnization
     * @return
     */
    Orgnization queryUniqueShrOrgnizationByOrgCode(Orgnization orgnization);


    /**
     * 根据SHR父组织ID查询组织
     * shr父组织ID存的是组织编码，所以使用组织编码去查询
     *
     * @param orgnization
     * @return
     */
    Orgnization queryUniqueShrParOrgnization(Orgnization orgnization);

    /**
     * 更新ESB数据
     *
     * @param orgnization
     */
    void updateForEsb(Orgnization orgnization);


    /**
     * 根据SHR部门ID获取组织数据
     *
     * @author 刘启鑫
     * @date 2020/8/22 17:45
     */
    Orgnization queryEmpOrgnizationByEmp(ExtEmployee employee);


}
